<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      body {
        padding: 0;
        margin: 0;
      }
      .money-area {
        position: relative;
        width: 100%;
        height: 100vh;
        background-color: rgb(197, 223, 246);
        overflow: hidden;
      }
      .money {
        position: absolute;
        top: 0;
        /* left: 0; */
        cursor: pointer;
        font-size: 16px;
        color: #fff;
        background: #f40d0d;
        border-radius: 12px;
        width: 50px;
        height: 88px;
        line-height: 88px;
        text-align: center;
        animation-name: rise;
        animation-iteration-count: infinite;
        /* animation-direction: alternate-reverse; */
      }

      @keyframes rise {
        0% {
          top: -100px;
        }
        100% {
          top: 100%;
          transform: rotate(270deg);
        }
      }
    </style>
    <script>
      let score = 0;
      function getMoney(event) {
        score++;
        document.getElementById("score").innerHTML = score;
        // event.target.style.display = "none";
        event.target.style["animation-play-state"] = "paused";
      }
    </script>
  </head>
  <body>
    <div class="money-area">
      <div id="score">0</div>
      <script>
        var mStr = "";
        var maxMoney = 10;
        while (maxMoney) {
          maxMoney--;
          console.log(Math.random());
          const duration = Math.random() * 10;
          const left = (Math.random() * 1000).toFixed(3);
          console.log(666.001, left);
          mStr += `
            <div class="money" style="left:${left}px;animation-duration:${duration}s" onclick="getMoney(event)">红包</div>
            `;
        }
        document.write(mStr);
      </script>
    </div>
  </body>
</html>
